<template>
  <div class="list-table">
    <template>
      <el-table v-loading="loading" tooltip-effect="darkTable" :data="dataList" border>
        <el-table-column :label="$t('项目名称')" align="center" prop="dealName" show-overflow-tooltip min-width="180">
          <template slot-scope="scope">
            <router-link
              target="_blank"
              :to="{ path:'/deal/home/dealBaseHome', query: { id: scope.row.id, dealType: scope.row.dealType, companyId: scope.row.companyId, menuKey: 'deal_after' }}"
              class="link_a"
            >{{ scope.row.dealName }}</router-link>
          </template>
        </el-table-column>
        <el-table-column :label="$t('项目负责人')" align="center" prop="personChargeName" show-overflow-tooltip min-width="100" />
        <el-table-column :label="$t('投资时间')" align="center" prop="dateInvestmentFact" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.dateInvestmentFact) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('投资成本') + $t('金额单位')" align="center" prop="fk" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span>{{ moneyFormat(scope.row.fk, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('回款金额') + $t('金额单位')" align="center" prop="hk" show-overflow-tooltip min-width="120">
          <template slot-scope="scope">
            <span>{{ moneyFormat(scope.row.hk, 'w') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('最新估值') + $t('金额单位')" align="center" prop="gz" show-overflow-tooltip min-width="100">
          <template slot-scope="scope">
            <span>{{ moneyFormat(scope.row.gz, 'w') }}</span>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList(param)"
      />
    </template>
  </div>
</template>

<script>
import {
  getDealDateListByProvinceId,
  getDealIndustryList,
  getDealInvestTypeList,
  getDealTypeList
} from '@/api/base/deal/dealBase'

export default {
 data() {
    return {
      total: 0,
      loading: false,
      queryParams: {
        provinceRegistered: undefined,
        investmentType: undefined,
        industryFirst: undefined,
        dealType: undefined,
        pageNum: 1,
        pageSize: 10
      },
      dataList: [],
      tableList: [],
      param: {
        provinceId: undefined,
        type: undefined,
        provinceName: undefined,
        industryFirst: undefined,
        investmentType: undefined,
        dealType: undefined
      }
    }
  },
  created() {
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList(data) {
      this.loading = true
      if (data != null) {
        console.log('data', data)
        this.reset()
        // 点击各省项目数据弹窗打开调用的
        if (data.type === 'province' && data.provinceId != null) {
          this.queryParams.provinceRegistered = data.provinceId
          this.param.provinceId = data.provinceId
          this.param.provinceName = data.provinceName
          this.param.type = data.type
          getDealDateListByProvinceId(this.queryParams).then(response => {
            this.dataList = response.rows
            this.total = response.total
            this.loading = false
          })
        } else if (data.type === 'investType' && data.investmentType != null) {
          this.queryParams.investmentType = data.investmentType
          this.param.investmentType = data.investmentType
          this.param.type = data.type
          getDealInvestTypeList(this.queryParams).then(response => {
            this.dataList = response.rows
            this.total = response.total
            this.loading = false
          })
        } else if (data.type === 'industryType' && data.industryFirst != null) {
          this.queryParams.industryFirst = data.industryFirst
          this.param.industryFirst = data.industryFirst
          this.param.type = data.type
          getDealIndustryList(this.queryParams).then(response => {
            this.dataList = response.rows
            this.total = response.total
            this.loading = false
          })
        } else if (data.type === 'dealType' && data.paramDealType != null) {
          console.log('-----data------', data)
          this.queryParams.dealType = data.dealType
          this.param.dealType = data.dealType
          this.param.paramDealType = data.paramDealType
          this.param.type = data.type
          getDealTypeList(this.queryParams).then(response => {
            this.dataList = response.rows
            this.total = response.total
            this.loading = false
          })
        }
      }
    },
    reset() {
      this.param = {
        provinceId: undefined,
        type: undefined,
        provinceName: undefined,
        investmentType: undefined
      }
    },
    /** 搜索按钮操作 */
    queryHandle() {
      this.queryParams.pageNum = 1
      this.getList(this.param)
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryHandle()
    }
  }
}

</script>

